﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Studentperformancemanagement
{
    class Class1
    {
        public static readonly string constring = "server=.;database=Schools;uid=sa;pwd=123456a";
        public static DataTable Getdata(string sql)//查询和初始化
        {
            SqlConnection connection = new SqlConnection(constring);
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
            DataTable data = new DataTable();
            connection.Open();
            adapter.Fill(data);
            return data;
        }

        public static int Adddeletemodify(string sql)//修改、删除、添加
        {
            SqlConnection connection = new SqlConnection(constring);
            connection.Open();
            SqlCommand command = new SqlCommand(sql, connection);
            return command.ExecuteNonQuery();
        }
    }
}
